// const { defineConfig } = require('@vue/cli-service')
const path = require('path') 
const resolve = (dir) => path.join(__dirname, dir)
// const test = 'http://39.103.231.233:8089'   // 正式环境
// const test = 'http://39.103.231.233:8087'   // 测试环境
const test = 'http://39.103.231.233:8086'   // 开发环境

const vueConfig = {
    outputDir: 'merchant',
    publicPath:"/",
    chainWebpack: config => {
        config.resolve.symlinks(true) // 修复热更新失效
        // 如果使用多页面打包，使用vue inspect --plugins查看html是否在结果数组中
        config.plugin('html').tap(args => {
            // 修复 Lazy loading routes Error
            args[0].chunksSortMode = 'none'
            return args
        })
        config.resolve.alias // 添加别名
        .set('@', resolve('src'))
        .set('@assets', resolve('src/assets'))
        .set('@components', resolve('src/components'))
        .set('@views', resolve('src/views'))
        .set('@store', resolve('src/store'))
        .set('@request', resolve('src/request'))
    },
    devServer: {
        // development server port 8000
        port: 8080,
        proxy: {
            '/api': {
                target: test,
                changeOrigin: true,
                pathRewrite: {
                    '/api': ''
                }
            },
        }
    },
    //...其他配置
    css: {
        loaderOptions: {
            postcss: {
                plugins: [
                    require('postcss-pxtorem')({
                        rootValue: 37.5,
                        propList: ['*']
                    })
                ]
            }
        }
    }
}

module.exports = vueConfig

